home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Unix / GopherTools / jughead / jughead.0.9 / tree.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-11  |  2.7 KB  |  82 lines

  1. /*****************************************************************************
  2.  * File:    tree.h
  3.  *
  4.  * Author:    Rhett "Jonzy" Jones
  5.  *        jonzy@cc.utah.edu
  6.  *
  7.  * Date:    February 27, 1993
  8.  *
  9.  * Modifed:    March 6, 1993, by Rhett "Jonzy" Jones.
  10.  *        to support positions.
  11.  *
  12.  *        March 10, 1993, by Rhett "Jonzy" Jones.
  13.  *        Added the typedef for Element, and prototypes for
  14.  *        BinarySearch() and NumberOfLeafs().
  15.  *
  16.  *        March 13, 1993, by Rhett "Jonzy" Jones.
  17.  *        Altered the prototype for PrintTree() to now have the
  18.  *        'hostTree' flag.
  19.  *
  20.  *        March 16, 1993, by Rhett "Jonzy" Jones.
  21.  *        BinarySearch() now returns a long instead of a short.
  22.  *
  23.  *        March 28, 1993, by Rhett "Jonzy" Jones.
  24.  *        Added ifdef sun then don't use prototypes.
  25.  *
  26.  *        May 5, 1993, by Rhett "Jonzy" Jones.
  27.  *        Modified the prototyped forward declaration of BinarySearch()
  28.  *        to support partial word searches.
  29.  *
  30.  * Description:    Header file for use with "tree.c".  Simply defines a type,
  31.  *        prototypes a few routines, and declares a variable as
  32.  *        extern.
  33.  *
  34.  * Bugs:    No known bugs.
  35.  *
  36.  * Copyright:    Copyright 1993, University of Utah Computer Center.
  37.  *        This source may be freely distributed as long as this copyright
  38.  *         notice remains intact, and is in no way used for any monetary
  39.  *         gain, by any institution, business, person, or persons.
  40.  *
  41.  ****************************************************************************/
  42.  
  43. #define NIL        (void *)0L
  44.  
  45. typedef struct lNode { long        where;        /* The position for a word. */
  46.                struct lNode    *next;        /* Next position for a word. */
  47.              } ListType;
  48.  
  49. typedef struct tNode { char        *word;        /* A word from the display str. */
  50.                ListType        *positions;    /* List of positions. */
  51.                struct tNode    *left,        /* Left side of the tree. */
  52.                     *right;        /* Right side of the tree. */
  53.              } TreeType;
  54.  
  55. typedef struct { char            *word;        /* The word. */
  56.          ListType        *positions;    /* List of file positions. */
  57.            } Element;
  58.  
  59. #ifdef USEPROTOTYPES
  60.     extern short    InList(TreeType *node,long where);
  61.     extern void    DestroyList(ListType *list);
  62.     extern ListType    *BuildList(ListType *node,long where);
  63.     extern long    BinarySearch(char *what2Find,Element *data,long size,char **asterik,size_t *asterikPos);
  64.     extern long    NumberOfLeafs(TreeType *node);
  65.     extern TreeType    *WhatBranch(TreeType *node,char *word);
  66.     extern void    BuildTree(TreeType **root,char *word,long where);
  67.     extern long    NumberOfListNodes(ListType *positions);
  68.     extern void    PrintTree(TreeType *node,int hostTree);
  69. #else
  70.     extern short    InList();
  71.     extern void    DestroyList();
  72.     extern ListType    *BuildList();
  73.     extern long    BinarySearch();
  74.     extern long    NumberOfLeafs();
  75.     extern TreeType    *WhatBranch();
  76.     extern void    BuildTree();
  77.     extern long    NumberOfListNodes();
  78.     extern void    PrintTree();
  79. #endif
  80.  
  81. extern TreeType    *root;            /* The root of the tree. */
  82.